import request from '@/utils/request'

/**
 * 查询销售业绩列表
 * @param pageNum
 * @param pageSize
 */
const getList = function(date) {
  return request({
    url: '/sysOrder/getSales?date=' + date,
    method: 'get',
    data: {}
  })
}
const addDate = function(date, days) {
  if (days == undefined || days == '' ) {
    days = 1
  }
  var date1 = new Date(date)
  date1.setDate(date1.getDate() + Number(days))
  var month = date1.getMonth() + 1
  var day = date1.getDate()
  return date1.getFullYear() + '-' + getFormatDate(month) + '-' + getFormatDate(day)
}
const getFormatDate = function(arg) {
  if (arg == undefined || arg == '') {
    return ''
  }
  var re = arg + ''
  if (re.length < 2) {
    re = '0' + re
  }
  return re
}
export const sale = {
  getList: getList,
  addDate: addDate
}
/**
 * 参数处理
 * @param params
 */
const getParam = function(params) {
  let ret = ''
  for (const it in params) {
    ret += encodeURIComponent(it) + '=' + encodeURIComponent(params[it]) + '&'
  }
  return ret.substr(0 ,ret.length - 1)
}
